<div class="modal fade" id="modalEmpresas" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="glyphicon glyphicon-remove-circle"></i></button>
                <h3 id="myModalLabel">Nueva Empresa</h3>
            </div>
            <form id="agregaempresa" name="agregaempresa" action="<?php echo base_url();?>empresas/agregar" method="post">
            <div class="modal-body">
                <input type="hidden" id="modo" name="modo" value="update">
                <input type="hidden" id="idempresa" name="idempresa" value="">
                <!--Cambio a TabPanel para el alta de empresas -->
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#tab1" data-toggle="tab">Generales</a></li>
                        <li><a href="#tab2" data-toggle="tab">Contacto</a></li>
                        <li><a href="#tab3" data-toggle="tab">Facturaci&oacute;n</a></li>
                        <li><a href="#tab4" data-toggle="tab">Usuario</a></li>
                    </ul>
                    <div class="tab-content" style="padding-top: 10px;">
                        <div class="tab-pane active" id="tab1">
                          <div class="well">
                            <legend>Datos de la Empresa</legend>
                            <div class="row">
                                <div class="col-xs-7">
                                    <div class="form-group">
                                        <label for="nombreempresa">Raz&oacute;n Social</label>
                                        <input class="form-control uppercase" id="nombreempresa" name="nombreempresa" required title="Debe escribir la razón social de la empresa." />
                                    </div>
                                </div>
                                <div class="col-xs-5">
                                    <div class="form-group">
                                        <label for="rfcempresa">R.F.C.</label>
                                        <input class="form-control uppercase" id="rfcempresa" name="rfcempresa" required title="Ejemplo: AAAA121212MMM" pattern="^([A-Za-zÑ\x26]{3,4}([0-9]{2})(0[1-9]|1[0-2])(0[1-9]|1[0-9]|2[0-9]|3[0-1])[A-Za-z|\d]{3})$" />
                                    </div>
                                </div>
                             </div>
                            <div class="row">
                                <div class='col-xs-12'>
                                    <div class="form-group">
                                        <label for="domicilioempresa">Domicilio Fiscal</label>
                                        <textarea class="form-control uppercase" id="domicilioempresa" name="domicilioempresa" required row="3" ></textarea>
                                    </div>
                                </div>
                            </div>
                            <div class='row'>
                                <div class='col-xs-6'>
                                    <div class="form-group">
                                        <label for="estadoempresa">Estado</label>
                                        <?php echo form_dropdown("estadoempresa", $estados, null, "id='cmbestados' class='form-control'"); ?>
                                    </div>
                                </div>
                                <div class='col-xs-6'>
                                    <div class="form-group">
                                        <label for="ciudadempresa">Ciudad</label>
                                        <?php echo form_dropdown("ciudadempresa", array(), null, "id='cmbciudades' class='form-control'"); ?>
                                    </div>
                                </div>
                            </div>    
                          </div><!--Fin Datos Empresa-->
                        </div><!--Fin de Tab1-->
                        <div class="tab-pane" id="tab2">
                            <div class="well">
                                <legend>Datos de Contacto</legend>
                                <div class="row">
                                    <div class='col-xs-12'>
                                        <div class="form-group">
                                            <label for="contactoempresa">Nombre de Contacto</label>
                                            <input class="form-control uppercase" id="contactoempresa" name="contactoempresa" required title="Debe escribir un nombre de contacto." />
                                        </div>
                                    </div>
                                </div>
                                <div class='row'>
                                    <div class='col-xs-6'>
                                        <div class="form-group">
                                            <label for="telefonoempresa">Tel&eacute;fono Fijo</label>
                                            <div class='input-group'>
                                                <span class='input-group-addon'><span class="glyphicon glyphicon-phone-alt"></span></span>
                                                <input class="form-control uppercase" id="telefonoempresa" name="telefonoempresa" required pattern="^\+?\d{1,3}?[- .]?\(?(?:\d{2,3})\)?[- .]?\d\d\d[- .]?\d\d\d\d$" title="Ejemplo: 312-1234567" />
                                            </div>
                                        </div>
                                    </div>
                                    <div class='col-xs-6'>
                                        <div class="form-group">
                                            <label for="movilcontacto">Tel&eacute;fono M&oacute;vil</label>
                                            <div class='input-group'>
                                                <span class='input-group-addon'><span class="glyphicon glyphicon-phone"></span></span>
                                                <input class="form-control uppercase" id="movilcontacto" name="movilcontacto" required title="Ejemplo: 312-1234567" pattern="^\+?\d{1,3}?[- .]?\(?(?:\d{2,3})\)?[- .]?\d\d\d[- .]?\d\d\d\d$" />
                                            </div>
                                        </div>
                                    </div>
                                </div>   
                                <div class="row">
                                    <div class='col-xs-12'>
                                        <div class="form-group">
                                            <label for="emailcontacto">Email Contacto</label>
                                             <div class='input-group'>
                                                 <span class='input-group-addon'>@</span>
                                                <input class="form-control lowercase" id="emailcontacto" name="emailcontacto" pattern="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$" required title="Ejemplo: usuario@servidor.com" />
                                             </div>
                                        </div>
                                    </div>
                                </div>   
                            </div><!--Fin Datos Contacto-->
                        </div><!--Fin de Tab2-->
                        <div class="tab-pane" id="tab3">
                            <div class="well">
                                <legend>Datos de Facturación</legend>
                                <div class='row'>
                                    <div class='col-xs-6'>
                                        <div class="form-group">
                                            <label for="fechaingreso">Fecha Ingreso</label>
                                            <div class="input-group">
                                                <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                                                <input class="form-control uppercase" id="fechaingreso" name="fechaingreso" required />
                                            </div>
                                        </div>
                                    </div>
                                    <div class='col-xs-6'>
                                        <div class="form-group">
                                            <label for="diafacturacion">Día Facturación</label>
                                            <input class="form-control uppercase" id="diafacturacion" name="diafacturacion" required title="Valor entre [1-31]" />
                                        </div>
                                    </div>
                                </div>   
                                <div class='table-responsive'>
                                <?php $this->table->set_heading('Servicio','Costo Anual','Renta Dispositivo'); 
                                    foreach ($servicios as $row) { 
                                        $input1 = "<div class='input-group'>"
                                                                ."<span class='input-group-addon'>$</span>"
                                                                    .form_input(array(
                                                                            'type'        => 'number',
                                                                            'min'         => '100',
                                                                            'max'         => '3000',
                                                                            'class'       => 'form-control',
                                                                            'name'        => 'costoanual'.strtolower($row['servicio']),
                                                                            'id'          => 'costoanual'.strtolower($row['servicio']),
                                                                            'placeholder' => $row['costoanual'],
                                                                            'style'       => 'text-align:right;',
                                                                            'title'       => 'Valor entre 100 - 2000'
                                                                          ))
                                                                 ."<span class='input-group-addon'>.00</span>"
                                                          ."</div>";
                                        $input2 = "<div class='input-group'>"
                                                                ."<span class='input-group-addon'>$</span>"
                                                                    .form_input(array(
                                                                            'type'        => 'number',
                                                                            'min'         => '100',
                                                                            'max'         => '3000',
                                                                            'class'       => 'form-control',
                                                                            'name'        => 'costorenta'.strtolower($row['servicio']),
                                                                            'id'          => 'costorenta'.strtolower($row['servicio']),
                                                                            'placeholder' => $row['costorenta'],
                                                                            'style'       => 'text-align:right;',
                                                                            'title'       => 'Valor entre 100 - 2000'
                                                                          ))
                                                                  ."<span class='input-group-addon'>.00</span>"
                                                        ."</div>";
                                        $this->table->add_row(array('<div class="checkbox"><label><input type="checkbox" onclick="valida_costos(\''.$row['servicio'].'\',this);" name=servicios[] id='.$row['idservicio'].' value='.$row['servicio'].'>' .$row['servicio'].'</label></div>',$input1,$input2));

                                    }
                                    $plantilla = array('table_open' => '<table id="tablaEmpresas" class="table tableborder table-hover table-condensed">',
                                                        'heading_row_start'=> '<tr class="btn-info">',
                                                        'heading_row_end'=> '</tr>',
                                                        'heading_cell_start' => '<th>',
                                                        'heading_cell_end' => '</th>',
                                                        'cell_start' => '<td>',
                                                        'cell_end' => '</td>',
                                                        'cell_alt_start' => '<td>',
                                                        'cell_alt_end' => '</td>',
                                                        'table_close' => '</table>'); 
                                    $this->table->set_template($plantilla);
                                    echo $this->table->generate(); 
                                ?>
                                </div>
                            </div><!--Fin Facturacion-->
                        </div><!--Fin de Tab3-->
                        <div class="tab-pane" id="tab4">
                            <div class="well">
                                <legend>Usuario Administrador</legend>
                                <div class="row">
                                    <div class="col-xs-6">
                                        <div class="form-group">
                                            <label for="nombreusuario">Nombre Completo</label>
                                            <input class="form-control uppercase" id="nombreusuario" name="nombreusuario" required title="Debe escribir el nombre completo." />
                                        </div>
                                    </div>
                                    <div class="col-xs-6">
                                        <div class="form-group">
                                            <label for="emailuser">Email</label>
                                            <input class="form-control lowercase" id="emailuser" name="emailuser" required title="Ejemplo: usuario@servidor.com" pattern="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$" />
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-4">
                                        <div class="form-group">
                                            <label for="username">Login</label>
                                            <input class="form-control" id="username" onchange="checkLogin();" name="username" required title="Debe escribir un nombre de usuario." />
                                        </div>
                                    </div>
                                    <div class="col-xs-4">
                                        <div class="form-group">
                                            <label for="password">Contraseña</label>
                                            <input type="password" class="form-control" id="password" name="password" required title="Debe escribir una contraseña." />
                                        </div>
                                    </div>
                                    <div class="col-xs-4">
                                        <div class="form-group">
                                            <label for="passwordconfirm">Confirmaci&oacute;n</label>
                                            <input type="password" class="form-control" onchange="checkPassword();" id="passwordconfirm" name="passwordconfirm" required title="Debe escribir la misma contraseña." />
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div><!--Fin de Tab4-->
                   </div><!--Fin de Tab Content-->
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal" type="button" value="Cerrar">Cerrar</button>
                <button class="btn btn-primary" type="submit" value="Guardar">Guardar</button>
             </div>
            </form>
        
    </div>
</div>
</div>
